<template>
	<view class="tui-set-box">
		<tui-list-cell padding="0" :lineLeft="false" :arrow="true" @click="href(1)">
			<view class="tui-list-cell tui-info-box">
				<image v-if="userinfo.user_headimg" :src="userinfo.user_headimg" class="tui-avatar"></image>
				<image v-else src="/static/images/my/mine_def_touxiang_3x.png" class="tui-avatar"></image>
				<view>{{userinfo.user_tel}}</view>
			</view>
		</tui-list-cell>
		<tui-list-cell padding="0" :lineLeft="false" :arrow="true" @click="href(2)">
			<view class="tui-list-cell">
				地址管理
			</view>
		</tui-list-cell>
		<view class="tui-mtop">
			<tui-list-cell padding="0" :lineLeft="false" :arrow="true" @click="href(6)">
				<view class="tui-list-cell">
					账户与安全
				</view>
			</tui-list-cell>
			<tui-list-cell padding="0" :lineLeft="false" :arrow="true">
				<view class="tui-list-cell">
					支付设置
				</view>
			</tui-list-cell>
			<tui-list-cell padding="0" :lineLeft="false" :arrow="true" @click="href(3)">
				<view class="tui-list-cell">
					实名认证
				</view>
			</tui-list-cell>
		</view>
		<!-- <view class="tui-mtop">
			<tui-list-cell padding="0" :lineLeft="false" :arrow="true" @click="href(4)">
				<view class="tui-list-cell">
					关于我们
				</view>
			</tui-list-cell>
			<tui-list-cell padding="0" :lineLeft="false" :arrow="true" @click="href(5)">
				<view class="tui-list-cell">
					意见反馈
				</view>
			</tui-list-cell>
		</view> -->
       <!-- #ifndef MP-WEIXIN -->
       <view class="tui-exit" v-if="iswx">
       	<tui-button shape="circle" shadow type="danger" height="88rpx" @click="loginOut">退出登录</tui-button>
       </view>
       <!-- #endif -->
		


	</view>
</template>

<script>
	export default {
		data() {
			return {
				userinfo: '',
				iswx: true
			}
		},
		onShow() {
			this.tui.haslogin();
			if (this.tui.isLogin()) {
				this.userinfo = this.tui.getUserInfoData();
				// let ua = window.navigator.userAgent.toLowerCase()
				// if (ua.match(/MicroMessenger/i) == 'micromessenger') {
				// 	this.iswx=false;
				// }
			}

		},
		methods: {
			href(page) {
				let url = "";
				switch (page) {
					case 1:
						url = "../userInfo/userInfo"
						break;
					case 2:
						url = "../address/address"
						break;
					case 3:
						url = "../user/apply"
						break;
					case 4:
						url = "/pages/common/about/about"
						break;
					case 5:
						url = "/pages/my/feedback/feedback?page=mall"
						break;
					case 6:
						url = "../userInfo/setSafe"
						break;
					default:
						break;
				}
				uni.navigateTo({
					url: url
				})
			},

			loginOut() {
				let token = this.tui.getToken();
				let yiyu = this.tui;
				uni.showModal({
					title: '提示',
					content: '确定要退出当前账号吗？',
					success: function(res) {
						if (res.confirm) {
							let datas = {
								token: token,
							};
							let result = yiyu.request('user', 'post', datas, 1000, 1, '', 'logout');
							Promise.resolve(result).then((value) => {
								console.log(value)
								if (value.code == 200) {
									yiyu.logout();
									uni.navigateTo({
										url: '/pages/login/login'
									})
								} else {
									yiyu.toast(value.message);
								}
							})
						} else if (res.cancel) {
							return;
						}
					}
				});
			},
		}
	}
</script>

<style>
	.tui-set-box {
		padding-bottom: 20rpx;
		color: #333;
	}

	.tui-list-cell {
		display: flex;
		align-items: center;
		padding: 24rpx 30rpx;
		font-size: 30rpx;
	}

	.tui-info-box {
		font-size: 34rpx;
	}

	.tui-avatar {
		width: 140rpx;
		height: 140rpx;
		margin-right: 20rpx;
	}

	.tui-mtop {
		margin-top: 20rpx;
	}

	.tui-exit {
		padding: 100rpx 24rpx;
	}
</style>
